﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LLBannerList.aspx.cs" Inherits="HelloLLLLL.Blog.Admin.page.LLBannerList" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>layui</title>
    <meta name="renderer" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <link rel="stylesheet" href="../lib/layui-v2.5.5/css/layui.css" media="all" />
    <link rel="stylesheet" href="../css/public.css" media="all" />
</head>
<body>
  
<div class="layui-form">
    <div id="imgShow" style="position:absolute;display:none"><img width="400" src=""/></div>
      <table class="layui-table" lay-skin="line">
  <colgroup>
      <col width="220">
    <col width="280">
    <col width="290">
    <col width="180">
    <col width="80">
      <col width="120">
  </colgroup>
  <thead>
    <tr>
       <th>标题</th>
      <th>跳转地址</th>
      <th>图片地址</th>
      <th>是否展示</th>
      <th>排序值</th>
        <th>操作</th>
    </tr> 
  </thead>
  <tbody id="llContent">
     
  </tbody>
</table>   
  </div>
    <div id="demo7"></div>
      <script src="../lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
<script src="../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>
  
    layui.use(['laypage', 'layer'], function () {

        var laypage = layui.laypage
            , layer = layui.layer;

        //完整功能
        laypage.render({
            elem: 'demo7'
            , count: <%=BannerCount%>
            , layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
            , limit: 6
            , jump: function (obj) {
                $.ajax({
                    url: "/admin/AdminPostData.ashx?action=getBannerList&page=" + obj.curr + "&limit=" + obj.limit,
                    type: 'GET',
                    dataType: "JSON",
                    success: function (dd) {
                        //console.log(data);
                        if (dd.code == 1) {
                            var str = '';
                            for (var i = 0; dd.data != null && i < dd.data.length; i++) {
                                var item = dd.data[i];
                                var td = '<tr style="background: #009688; color:#fff">'
                                    + '<td>'+item.BanTitle + '</td>'
                                    + '<td><a style="color: #fff" href="' + item.BanAddr + '" target="_blank">' + item.BanAddr + '</a></td>'
                                    + '<td class="imgAddr">' + item.BanImgAddr + '</td>'
                                    + '<td>' + (item.BanIsShow == 1 ? "显示" : "不展示") + '</td>'
                                    + '<td>' + item.BanSort + '</td>'
                                    + '<td>'
                                    + '<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" href="javascript:void(0);">编辑</a>'
                                    + '<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" href="LLBannerList.aspx?action=delete&id=' + item.Id + '" targetID="' + item.Id + '">删除</a></td>'
                                    + '</tr>';

                                str += td;

                            }

                            $("#llContent").html(str);

                           

                        }

                        $(".imgAddr").mouseover(function (e) {
                            var str = $(this).text();
                            $("#imgShow").find("img").eq(0).attr("src", str);
                            $("#imgShow").css({ "left": e.pageX, "top": e.pageY, "display": "block", "zIndex": "99" });
                        });
                        $(".imgAddr").mouseout(function () {
                            $("#imgShow").css({ "display": "none" });
                        });
                        $(".data-count-edit").click(function () {

                            var tds = $(this).parent().parent().find("td");
                            var banTitle = $(tds[0]).text();
                            var banAddr = $(tds[1]).find("a").text();

                            var banImgAddr = $(tds[2]).text();
                            var banSort = $(tds[4]).text();

                            var banId = $(this).siblings().eq(0).attr("targetID");

                            var str = $(tds[2]).text();
                            var banIsShow = -1;
                            if (str == "显示") {
                                banIsShow = 1;
                            } else {
                                banIsShow = 0;
                            }


                            var index = layer.open({
                                title: '编辑Banner',
                                type: 2,
                                shade: 0.2,
                                maxmin: true,
                                shadeClose: true,
                                area: ['100%', '100%'],
                                content: '../page/LLBanner.aspx',
                                success: function (layero, index) {
                                    var body = layer.getChildFrame('body', index);
                                    console.log(body);
                                    body.find("#banId").val(banId);
                                    body.find('#banAddr').val(banAddr);
                                    body.find('#homeImg').val(banImgAddr);
                                    body.find('#banSort').val(banSort);
                                    body.find('#banIsShow').val(banIsShow);
                                    body.find("#showLLImg").attr("src", banImgAddr);
                                    body.find("#banTitle").val(banTitle);
                                }

                                , end: function () {
                                    location.reload();
                                }
                            });
                            $(window).on("resize", function () {
                                layer.full(index);
                            });
                            return false;
                        });
                    },
                    error: function (response) {
                        console.log(response);
                    }
                });

            }
        });
    });
    
</script>
</body>
</html>
